import redis



class RedisPool:
    def __init__(self,  config_section, decode_responses=True):

        self.config_section = config_section
        self.pool = None
        self.decode_responses = decode_responses
        self._config_redis()

    def _config_redis(self):
        self.host = 'r-bp1pcbqr6fo5kwnlft.redis.rds.aliyuncs.com'
        self.port = 6379
        self.db = 13
        self.password = 'yoXkwRvYHSaIu7QNjFUk'

    def get_pool(self):
        if self.pool is None:
            self.pool = redis.ConnectionPool(host=self.host, port=self.port, db=self.db, password=self.password,
                                             decode_responses=self.decode_responses)
        return self.pool

    def get_redis_conn(self):
        if self.pool is None:
            self.get_pool()
        return redis.StrictRedis(connection_pool=self.pool)


redis_pool = RedisPool( 'redis')
redis_conn = redis_pool.get_redis_conn()

sku_property = redis_conn.hgetall(
                '1515_' + '142202')
print(sku_property)